<!DOCTYPE html>
<html lang="en-us" id="extr-page">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen"
	href="../../global/css/bootstrap.min.css">
<link rel="stylesheet"
	href="../../global/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
<link rel="stylesheet" href="../../global/css/ztree/demo.css"
	type="text/css">
</head>
<body>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<form class="form-horizontal" onsubmit="return false" id="form"
			enctype="multipart/form-data">
			<fieldset>
				<input type="hidden" id="giftId" name="giftId">
				<input type="hidden" id="commissionId" name="commissionId">
				<div class="form-group">
					<label class="col-md-2 control-label">分拥类别:</label>
					<div class="col-md-10">
						<input class="form-control" type="text" readonly
							name="giftName" id="giftName" data-bv-notempty="true" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">分拥方式:</label>
					<div class="col-md-10" style="width: 120px">
						<select class="form-control input-sm" name="commissionType" id="commissionType">
							<option value="">请选择</option>
							<option value="1">固定金额</option>
							<option value="2">百分比</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">平台:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="admin" id="admin" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">地市代理:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="city" id="city" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">区县代理:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="country" id="country" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">会员:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="member" id="member" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">导购:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="shopper" id="shopper" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">讲师:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="lectorer" id="lectorer" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">经理:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="manage" id="manage" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">联盟:</label>
					<div class="col-md-10">
						<input type="text" class="form-control" 
							name="alliance" id="alliance" />
					</div>
				</div>
				<div class="form-actions">
					<div class="row" align="center">
						<div class="col-md-12">
							<button class="btn btn-primary"
								onclick="location.href='commissionList.html'">返回</button>
							<button id="submitbtn" class="btn btn-primary" type="submit"
								onclick="add()">
								<i class="fa fa-save"></i> 保存
							</button>
						</div>
					</div>
				</div>
			</fieldset>
		</form>
	</div>

	<script type="text/javascript"
		src="../../global/js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../global/js/jq.js"></script>
	<script type="text/javascript"
		src="../../global/js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../global/js/common.js"></script>
	<script type="text/javascript" src="../../global/layui/layui.js"></script>
	<script type="text/javascript" src="../../global/js/ajaxfileupload.js"></script>
	<script type="text/javascript">
	layui.use(['layer', 'laydate'], function () {
        var layer = layui.layer;
        var laydate = layui.laydate;
    });
		initData();
		function initData() {
			var giftName= getUrlParam("giftName");
			$("#giftName").val(decodeURI(decodeURI(giftName)));
			$("#giftId").val(getUrlParam("giftId"));
			var commissionId = getUrlParam("commissionId");
			console.info(commissionId)
			debugger
			if(commissionId!=null && commissionId!="null"){
				//数据回显
				$("#commissionId").val(getUrlParam("commissionId"));
				if(getUrlParam("commissionType")!=null && getUrlParam("commissionType")!="null")
				$("#commissionType").val(getUrlParam("commissionType"));
				if(getUrlParam("admin")!=null && getUrlParam("admin")!="null")
				$("#admin").val(getUrlParam("admin"));
				if(getUrlParam("city")!=null && getUrlParam("city")!="null")
				$("#city").val(getUrlParam("city"));
				if(getUrlParam("country")!=null && getUrlParam("country")!="null")
				$("#country").val(getUrlParam("country"));
				if(getUrlParam("member")!=null && getUrlParam("member")!="null")
				$("#member").val(getUrlParam("member"));
				if(getUrlParam("shopper")!=null && getUrlParam("shopper")!="null")
				$("#shopper").val(getUrlParam("shopper"));
				if(getUrlParam("lectorer")!=null && getUrlParam("lectorer")!="null")
				$("#lectorer").val(getUrlParam("lectorer"));
				if(getUrlParam("manage")!=null && getUrlParam("manage")!="null")
				$("#manage").val(getUrlParam("manage"));
			}
		}
		

		$('#form').bootstrapValidator();

		//新增商品
		function add() {
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
			if (!bootstrapValidator.isValid()) {
				return;
			}
			$("form").ajaxSubmit({
				type : 'post',
				url : '/clyjCom/saveCom',
				traditional : true,
				contentType : "application/json; charset=utf-8",
				success : function(data) {
					layer.msg(data.data, {
						shift : -1,
						time : 1000
					}, function() {
						location.href = "commissionList.html";
					});
				}
			})

		}
		
	</script>
</body>
</html>